package com.yazi.mxz.common.entity.beans;

import com.myframework.smhj.hibernate.Entity;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.SEQUENCE;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Admin entity. @author MyEclipse Persistence Tools
 */
@javax.persistence.Entity
@Table(name = "MXZ_ADMIN", schema = "MXZ", uniqueConstraints = @UniqueConstraint(columnNames = "NAME"))
public class Admin extends Entity implements java.io.Serializable {

	// Fields

	private Long adminId;
	private String name;
	private String password;
	private String realName;
	private Long loginTime;
	private Set<AdminRole> adminRoles = new HashSet<AdminRole>(0);

	// Constructors

	/** default constructor */
	public Admin() {
	}

	/** minimal constructor */
	public Admin(String name, String password, Long loginTime) {
		this.name = name;
		this.password = password;
		this.loginTime = loginTime;
	}

	/** full constructor */
	public Admin(String name, String password, String realName, Long loginTime,
			Set<AdminRole> adminRoles) {
		this.name = name;
		this.password = password;
		this.realName = realName;
		this.loginTime = loginTime;
		this.adminRoles = adminRoles;
	}

	// Property accessors
	@SequenceGenerator(name = "generator", sequenceName = "SEQ_ADMIN")
	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "generator")
	@Column(name = "ADMIN_ID", unique = true, nullable = false, precision = 15, scale = 0)
	public Long getAdminId() {
		return this.adminId;
	}

	public void setAdminId(Long adminId) {
		this.adminId = adminId;
	}

	@Column(name = "NAME", unique = true, nullable = false, length = 60)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "PASSWORD", nullable = false, length = 60)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "REAL_NAME", length = 60)
	public String getRealName() {
		return this.realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	@Column(name = "LOGIN_TIME", nullable = false, precision = 15, scale = 0)
	public Long getLoginTime() {
		return this.loginTime;
	}

	public void setLoginTime(Long loginTime) {
		this.loginTime = loginTime;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "admin")
	public Set<AdminRole> getAdminRoles() {
		return this.adminRoles;
	}

	public void setAdminRoles(Set<AdminRole> adminRoles) {
		this.adminRoles = adminRoles;
	}

}